const express = require('express')
const app = express()
var logger = require('morgan');
app.use(logger('dev'));
const port = 6666
let bodyParser = require('body-parser')
let ocrReq = require('./ocr')
let schemeReq = require('./scheme')
app.use(bodyParser.json({ limit: "2100000kb" }));


app.use(bodyParser.json())
app.get('/', (req, res) => {
	res.send('Hello World!')
})

app.post('/image', async (req, res) => {
	let tempJson = req.body
	// console.log(tempJson)
	let OcrResult = await ocrReq(tempJson.image)
	let result = await schemeReq(tempJson.x, tempJson.y, tempJson.yoloData, OcrResult)
	console.log(result)
	return res.json({ "success": true, "data": result })
})

app.listen(port, '0.0.0.0', () => {
	console.log(`Example app listening at http://0.0.0.0:${port}`)
})